using System;
using System.Collections.Generic;
using System.Text;
using Barrage.Global;

namespace Spacedash.Logic.RaceStates
{
    /// <summary>
    /// State used when the race itself has finished, to give the players some time to read the information onscreen and rejoice.
    /// </summary>
    public class FinishingRaceState : RaceState
    {
        /// <summary>
        /// \internal State identifier
        /// </summary>
        public override RaceStateList State
        {
            get { return RaceStateList.Finishing; }
        }

        const float FINISH_TIMER = 10f;
        float startTime;
        /// <summary>
        /// Remaining time in seconds to finish this state
        /// </summary>
        public float Remaining { get { return FINISH_TIMER - (Timer.DefaultTimer.TotalTimeSeconds - startTime); } }

        
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="race">Race that's creating this instance</param>
        public FinishingRaceState(Race race)
            : base(race)
        {
            startTime = Timer.DefaultTimer.TotalTimeSeconds;
        }

        /// <summary>
        /// \internal Updates the timer and changes the race state when FINISH_TIMER seconds have passed
        /// </summary>
        public override void Update()
        {
            if (Remaining <= 0)
                race.State = new FinishedRaceState(race);
        }
    }
}
